<template>
  <!-- <product-detail :is-edit='false'></product-detail> -->
  <div class="app-container">

<!--    <el-card class="table-container">-->
<!--      <i class="el-icon-tickets"></i>-->
<!--      <span>数据列表</span>-->
<!--      <el-table ref="productTable" :data="list" style="width: 100%" v-loading="listLoading" border>-->
<!--        <el-table-column label="序号" type="index" width="50"></el-table-column>-->
<!--        <el-table-column label="收货人" width="250" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <p>{{scope.row.userName}}</p>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--&lt;!&ndash;        <el-table-column label="商品图片" align="center">&ndash;&gt;-->
<!--&lt;!&ndash;          <template slot-scope="scope">&ndash;&gt;-->
<!--&lt;!&ndash;            <img style="height: 80px" :src="scope.row.imageUrl" />&ndash;&gt;-->
<!--&lt;!&ndash;          </template>&ndash;&gt;-->
<!--&lt;!&ndash;        </el-table-column>&ndash;&gt;-->
<!--&lt;!&ndash;        <el-table-column label="商品名称" align="center">&ndash;&gt;-->
<!--&lt;!&ndash;          <template slot-scope="scope">&ndash;&gt;-->
<!--&lt;!&ndash;            <p>{{scope.row.productName}}</p>&ndash;&gt;-->
<!--&lt;!&ndash;          </template>&ndash;&gt;-->
<!--&lt;!&ndash;        </el-table-column>&ndash;&gt;-->
<!--&lt;!&ndash;        <el-table-column label="收货地址" align="center">&ndash;&gt;-->
<!--&lt;!&ndash;          <template slot-scope="scope">&ndash;&gt;-->
<!--&lt;!&ndash;            <p>{{scope.row.province}} {{scope.row.city}} {{scope.row.address}}</p>&ndash;&gt;-->
<!--&lt;!&ndash;          </template>&ndash;&gt;-->
<!--&lt;!&ndash;        </el-table-column>&ndash;&gt;-->
<!--        <el-table-column label="发货状态" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <p>{{scope.row.state==0?'待发货':'已发货'}}</p>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column label="操作" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button-->
<!--              size="mini"-->
<!--              type="warning"-->
<!--              @click="handleShowLog(scope.$index, scope.row)"-->
<!--            >{{scope.row.state==0?'确认发货':'取消发货'}}</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--      </el-table>-->
<!--      <el-dialog title="提示" :visible.sync="showToast" width="30%" >-->
<!--        <span>确认执行该操作？</span>-->
<!--        <span slot="footer" class="dialog-footer">-->
<!--          <el-button @click="showToast = false">取 消</el-button>-->
<!--          <el-button type="primary" @click="handleChangeState" :loading="loading">确 定</el-button>-->
<!--        </span>-->
<!--      </el-dialog>-->
<!--    </el-card>-->
  </div>
</template>
<script>
export default {
  name: 'addProduct',
  data() {
    return {
      list: null,
      showForm: false,
      showToast: false,
      state:'',
      pid:'',
    }
  },
  created() {
    this.getList()
  },
  // components: { ProductDetail }
  methods: {
    // 获取商品列表
    async getList() {
      this.listLoading = true
      // fetchList(this.listQuery).then(response => {
      //   this.listLoading = false;
      //   this.list = response.data.list;
      //   this.total = response.data.total;
      // });

      const { data: res } = await this.$http.post('pro/redeemRecordListAll')
      if (res.code == 200) {
        this.listLoading = false
        this.list = res.data
      } else {
        return this.$message.error('获取兑换商品列表失败!')
      }
    },
    // 点击确认或者取消发货
    handleShowLog(index, row) {
      this.showToast = true
      this.state = (row.state == 0)?1:0;
      this.pid = row.pid;

    },
    // 修改发货状态
    async handleChangeState(){
      this.loading = true
      const { data: res } = await this.$http.get('pro/productSendState', {
        params: {
          id: this.pid,
          state: this.state
        }
      })
      this.loading = false
      this.showToast = false
      this.getList()
      // location.reload()
    }
  }
}
</script>
<style>
</style>
